/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package character_11_;

import java.util.concurrent.BlockingQueue;

/**
 *
 * @author Administrator
 */
public class Consumer3 implements Runnable{
    private BlockingQueue<Integer> productQueue;
    
    public Consumer3(BlockingQueue<Integer> productQueue){
    
        this.productQueue = productQueue;
    }
    
    public void run(){
    
        System.out.println("消费者开始消耗整数....");
        for (int i = 0; i <= 10; i++) {
            try {
                int product = productQueue.take();
                System.out.println("消费者消费整数" + product);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
